<template>
    <div>
        <Form :label-width="120" inline>
            <Form-item label="属地区划:">
                <area-linkage :areaCode.sync="queryParam.ssca0043"></area-linkage>
            </Form-item>
            <Form-item label="家庭编号：">
                <Input v-model="queryParam.azdf0001"   placeholder=""
                       style="width: 160px"/>
            </Form-item>
            <Form-item label="低保证号：">
                <Input v-model="queryParam.ssca0014"   placeholder=""
                       style="width: 160px"/>
            </Form-item>
            <Form-item label="姓名：">
                <Input v-model="queryParam.azcp0003"   placeholder=""
                       style="width: 120px"/>
            </Form-item>
            <Form-item label="证件号码：">
                <Input v-model="queryParam.azcp0001"   placeholder=""
                       style="width: 150px"/>
            </Form-item>
            <span v-if="show">
                <Form-item label="性别：">
                <dictSelect dictCode="sex" :bindData.sync="queryParam.azcp0004" :sel_val='queryParam.azcp0004'
                            style="width: 100px"/>
            </Form-item>
            <Form-item label="年龄：">
              <Input-number    v-model="queryParam.age_begin"></Input-number>~
              <Input-number    v-model="queryParam.age_end"></Input-number>
            </Form-item>
            <Form-item label="民族：">
                <dictSelect dictCode="nation" :bindData.sync="queryParam.azcp0007" :sel_val='queryParam.azcp0007'
                            style="width: 100px"/>
            </Form-item>
            <Form-item label="健康状况：">
                <dictSelect dictCode="health" :bindData.sync="queryParam.azcp0009" :sel_val='queryParam.azcp0009'
                            style="width: 130px"/>
            </Form-item>
            <Form-item label="残疾类别：">
                <dictSelect dictCode="disabilitytype" :bindData.sync="queryParam.azcp0504" :sel_val='queryParam.azcp0504'
                            style="width: 100px"/>
            </Form-item>
            <Form-item label="残疾等级：">
                <dictSelect dictCode="disabilityclass" :bindData.sync="queryParam.azcp0505" :sel_val='queryParam.azcp0505'
                            style="width: 100px"/>
            </Form-item>
            <Form-item label="劳动能力丧失情况：">
                <dictSelect dictCode="workability" :bindData.sync="queryParam.azcp0502" :sel_val='queryParam.azcp0502'
                            style="width: 150px"/>
            </Form-item>

            <Form-item label="救助类型：">
                <Select v-model="queryParam.ssca0002" placeholder="" style="width: 160px"   >
                    <Option value="100">城市低保 </Option>
                    <Option value="101">城市单人保 </Option>
                    <Option value="102">城市因病致贫</Option>
                </Select>
            </Form-item>
            <Form-item label="有无核对报告：">
                <Select v-model="queryParam.finishCheck" placeholder="" style="width: 160px"   >
                    <Option value="1">有核对报告 </Option>
                    <Option value="0">无核对报告 </Option>
                </Select>
            </Form-item>
            </span>

            <div style="display: inline-block;cursor:pointer" @click="showHidden">
                <template v-if="show">
                    <Form-item label="收起条件" style="cursor:pointer">
                        <div class="ivu-form-item">
                        <span class="ivu-input-suffix">
                          <Icon type="ios-arrow-up"/>
                        </span>
                        </div>
                    </Form-item>
                </template>
                <template v-else>
                    <Form-item label="展开条件" style="cursor:pointer">
                        <div class="ivu-form-item">
                        <span class="ivu-input-suffix">
                            <Icon type="ios-arrow-down"/>
                        </span>
                        </div>
                    </Form-item>
                </template>
            </div>
            <Row class="button_row">
                <span style="float: right;">
                    <Button type="primary" style="" @click="searchQuery2">查询</Button>
                <Button type="primary" style="margin-left: 8px" @click="searchReset2">重置</Button>
                </span>
            </Row>
        </Form>
        <Modal v-model="hdInfoModal" title="家庭核对信息情况" width="1000" style="position:relative;">
            <div>
                <Table :columns="columnsHdInfo" :data="hdInfoData" :loading="Loading">
                    <template slot-scope="{ row  }" slot="action">
                        <!--                    <Button type="info" size="small" style="margin-right: 5px" @click="handleEdit(index)">编辑</Button>-->
                        <!--                    <Button type="success" size="small" style="margin-right: 5px" @click="remove(row)">删除计划</Button>-->
                        <!--                    <Button type="success" size="small" style="margin-right: 5px" @click="handleView(index)">查看详细</Button>-->
                        <Button v-if="row.cbxx0015!= null||row.cbxx0015!= undefined||row.cbxx0015!= ''" type="success" size="small"   style="margin-right: 5px" @click="showHdbg(row.cbxx0015)">查看核对报告</Button>
                    </template>
                </Table>
                <Page :total="dataCountNoValidateInfo" :page-size="pageSize" show-total class="paging"
                      @on-change="handleTableChangeV"></Page>
            </div>
            <br>
            <br>
            <div slot="footer">
                <Button type="text" size="large" @click="hdInfoModal = false">关闭</Button>
            </div>
        </Modal>
        <div class="button_row">
            <Table :columns="columns" :data="tableData" :loading="Loading">
                <template slot-scope="{ row  }" slot="action">
                    <!--                    <Button type="info" size="small" style="margin-right: 5px" @click="handleEdit(index)">编辑</Button>-->
                    <!--                    <Button type="success" size="small" style="margin-right: 5px" @click="remove(row)">删除计划</Button>-->
                    <!--                    <Button type="success" size="small" style="margin-right: 5px" @click="handleView(index)">查看详细</Button>-->
                    <Button type="success" size="small"   style="margin-right: 5px" @click="hdbg(row.azcp0001)">家庭核对信息情况</Button>
                </template>
            </Table>
            <Page :total="dataCount" :page-size="pageSize" show-total class="paging"
                  @on-change="handleTableChange"></Page>
        </div>
        <pdfModal ref="pdfModal"></pdfModal>
    </div>
</template>

<script>
    import { postAction } from '@/api/request'
    import {CommonMixin} from '@/views/common/js/CommonMixin'
    import dictSelect from '@/components/dictSelect/dictSelect.vue'
    import DateFormat from '@/plugins/format.js'
    import pdfModal from '@/components/system/pdfModal'

    export default {
        mixins: [CommonMixin],
        components: {
            dictSelect,pdfModal
        },
        data() {
            return {
                show: false,
                rules: {
                    ccxx0001: [
                        { required: true, message: '复核月度不能为空', trigger: 'blur',
                            pattern: /.+/ }
                    ],
                    ccxx0002: [
                        { required: true, message: '计划执行时间不能为空', trigger: 'blur',
                            pattern: /.+/ }
                    ],
                },
                hdInfoModal:false,
                dataCountNoValidateInfo:0,
                hdInfoData:[],
                columnsHdInfo:[
                    {
                        title: '户主姓名',
                        key: 'cbxx0001',
                        align: 'center',
                        width: '100'
                    },
                    {
                        title: '证件号码',
                        key: 'cbxx0002',
                        align: 'center',
                        width: '200'
                    },{
                        title: '采集时间',
                        key: 'cbxx0003',
                        align: 'center',
                        width: 150,render: (h, params) => {
                            let value = params.row.cbxx0003
                            if (typeof (value) === 'undefined' || value === null || value === '' || value === undefined) {
                                value = '--'
                            }else{
                                value = DateFormat( value, 'YYYY-MM-DD')
                            }
                            return h('span', value + ' ')
                        }
                    },
                    {
                        title: '核对申请时间',
                        key: 'cbxx0004',
                        align: 'center',
                        width: 150,render: (h, params) => {
                            let value = params.row.cbxx0004
                            if (typeof (value) === 'undefined' || value === null || value === '' || value === undefined) {
                                value = '--'
                            }else{
                                value = DateFormat( value, 'YYYY-MM-DD')
                            }
                            return h('span', value + ' ')
                        }
                    },{
                        title: '是否为最新核对报告',
                        key: 'cbxx0007',
                        align: 'center',
                        width: '200',
                        render: (h, params) => {
                            let value = params.row.cbxx0007
                            if (typeof (value) === 'undefined' || value === null || value === '' || value === undefined) {
                                value = ''
                            } else if(value === '1'){
                                value = "是"
                            } else if(value === '0'){
                                value = "否"
                            }
                            return h('span', value + ' ')
                        }
                    },
                    {
                        title: '操作',
                        key: 'action',
                        align: 'center',
                        slot: 'action',
                        width: '150',
                        className: 'nopadding',
                    }
                ],
                columns: [
                    // {
                    //     title: 'oss',
                    //     key: 'cbxx0015',
                    //     align: 'center',
                    //     width: '100'
                    // },
                     {
                        title: '救助类型',
                        key: 'ssca0002',
                        align: 'center',
                        width: '200',

                    },{
                        title: '属地区划',
                        key: 'ssca0043',
                        align: 'center',
                        width: '160'
                    },
                    {
                        title: '户主姓名',
                        key: 'hzname',
                        align: 'center',
                        width: '100'
                    },
                    {
                        title: '证件号码',
                        key: 'azcp0001',
                        align: 'center',
                        width: '200'
                    },
                    {
                        title: '年龄',
                        key: 'prsnage',
                        align: 'center',
                        width: '100'
                    },
                    {
                        title: '家庭编号',
                        key: 'azdf0001',
                        align: 'center',
                        width: '180'
                    },
                    {
                        title: '低保证号',
                        key: 'ssca0014',
                        align: 'center',
                        width: '180'
                    },
                    {
                        title: '银行帐号',
                        key: 'ssca0011',
                        align: 'center',
                        width: '180'
                    },
                    {
                        title: '家庭人口',
                        key: 'ssca0051',
                        align: 'center',
                        width: '100'
                    },
                    {
                        title: '保障人口',
                        key: 'ssca0052',
                        align: 'center',
                        width: '100'
                    },
                    {
                        title: '家庭住址',
                        key: 'azdf0008',
                        align: 'center',
                        width: '180'
                    },
                    {
                        title: '分类救助上浮金额',
                        key: 'ssca0025',
                        align: 'center',
                        width: '100'
                    },
                    {
                        title: '高龄补贴金额',
                        key: 'ssca0065',
                        align: 'center',
                        width: '120'
                    },
                    {
                        title: '救助金额',
                        key: 'ssca0026',
                        align: 'center',
                        width: '100'
                    },
                    {
                        title: '总金额',
                        key: 'fAllMoney',
                        align: 'center',
                        width: '100'
                    },
                    {
                        title: '批准时间',
                        key: 'ssca0006',
                        align: 'center',
                        width: '120',
                        width: 150,render: (h, params) => {
                            let value = params.row.ssca0006
                            if (typeof (value) === 'undefined' || value === null || value === '' || value === undefined) {
                                value = '--'
                            }else{
                                value = DateFormat( value, 'YYYY-MM-DD')
                            }
                            return h('span', value + ' ')
                        }
                    },
                    {
                        title: '性别',
                        key: 'azcp0004',
                        align: 'center',
                        width: '100',
                        render: (h, params) => {
                            let value = params.row.azcp0004
                            if ( value === '1' ) {
                                value = '男'
                            } else if ( value === '2' ) {
                                value  = '女'
                            }
                            return h('span', value + ' ')
                        },
                    },
                    {
                        title: '户籍类别',
                        key: 'azcp0013',
                        align: 'center',
                        width: '140'
                    },
                    {
                        title: '民族',
                        key: 'azcp0007',
                        align: 'center',
                        width: '100'
                    },
                    {
                        title: '文化程度',
                        key: 'azcp0008',
                        align: 'center',
                        width: '120'
                    },
                    {
                        title: '健康状况',
                        key: 'azcp0009',
                        align: 'center',
                        width: '150'
                    },
                    {
                        title: '残疾类别',
                        key: 'azcp0504',
                        align: 'center',
                        width: '150'
                    },
                    {
                        title: '残疾等级',
                        key: 'azcp0505',
                        align: 'center',
                        width: '130'
                    },
                    {
                        title: '劳动能力丧失情况',
                        key: 'azcp0502',
                        align: 'center',
                        width: '150'
                    },
                    {
                        title: '操作',
                        fixed: 'right',
                        key: 'action',
                        align: 'center',
                        slot: 'action',
                        width: '150',
                        className: 'nopadding',
                    }
                ],
                tableData:[],
                Loading: false,
                url: {
                    list: "/api/ac/subsistence/ss08013Service/get100DbPageList",
                    edit: "/api/ac/subsistence/ss08012Service/update",
                    add: "/api/ac/subsistence/ss08012Service/insert",
                },
                queryParam: {ssca0002:'100',ssca0012:'100',age_begin:null,age_end:null},
                visible:false,
                show_detail:true,
                showSubmit:true,
                dataCount:0,
                pageSize:10,
                modal: false,
                title:""
            }
        },
        methods: {
            showHidden() {
                this.show = !this.show;
            },
            showHdbg(item){
                //查看核对报告
                this.$Modal.confirm({
                    title: '核对报告打印无效，是否确认？？',
                    onOk: () => {
                        this.$refs.pdfModal.showFile(item);
                        this.$refs.pdfModal.modalKey = this.uuid();
                    }
                })
            },
            handleTableChangeV(){

            },
            hdbg (item) {
                let that = this;
                var dataParam = {azcp0001:item}
                let url = "/api/ac/subsistence/ss08013Service/findSs08013";
                postAction(url, dataParam).then((res) => {
                    if (res.data.errcode != 0) {
                        this.$Message.error(res.data.errmsg);
                    } else {
                        that.hdInfoModal = true;
                        that.hdInfoData = res.data.data.results;
                        that.dataCountNoValidateInfo = res.data.data.totalRecord;
                    }
                }).finally(() => {
                    that.Loading = false;
                });
            },
            searchQuery2 () {
                this.loadData();
            },
            searchReset2 () {
                this.queryParam={ssca0002:'100',ssca0012:'100',age_begin:null,age_end:null};
                this.loadData(1);
            },
        },
        created() {
        },
    }
</script>
<style scoped>
    .paging {
        float: right;
        margin-top: 10px;
    }

    /deep/ .ivu-upload-list {
        display: none;
    }
</style>
